package com.shiro.demo.Config;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * @author Csea
 * @title
 * @date 2019/5/7 13:27
 */
public class CredentialMatcher extends SimpleCredentialsMatcher {
    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;
        String password = new String(usernamePasswordToken.getPassword());
        String dbPasswird = (String) info.getCredentials();
        System.out.println("CredentialMatcher的password是：" + dbPasswird + " dbPassword是：" + dbPasswird);
        return this.equals(password, dbPasswird);
    }
}
